Skip to content

gh-117716: Fix wave RIFF padding for data chunks#145237

Open
mbeijen wants to merge 1 commit intopython:mainfrom
mbeijen:gh-117716-riff-padding-wave-lib
Open

gh-117716: Fix wave RIFF padding for data chunks#145237
mbeijen wants to merge 1 commit intopython:mainfrom
mbeijen:gh-117716-riff-padding-wave-lib

Conversation

@mbeijen
Copy link
Contributor

@mbeijen mbeijen commented Feb 25, 2026

wave.Wave_write now writes the required RIFF pad byte when the data chunk size is odd.

Update RIFF chunk size calculations in both header writing and header patching so they include the alignment pad byte when present.

Add a regression test in test_wave.py that verifies odd-sized writes are padded, RIFF size is correct, and roundtrip reads preserve frame data.

wave.Wave_write now writes the required RIFF pad byte when the data chunk
size is odd.

Update RIFF chunk size calculations in both header writing and header
patching so they include the alignment pad byte when present.

Add a regression test in test_wave.py that verifies
odd-sized writes are padded, RIFF size is correct, and roundtrip reads
preserve frame data.
@encukou
Copy link
Member

encukou commented Mar 17, 2026

Looking at the document referenced in the issue (emphasis mine):

Binary data of fixed or variable size. The start of ckData is word-aligned with respect to the start of the RIFF file. If the chunk size is an odd number of bytes, a pad byte with value zero is written after ckData. Word aligning improves access speed (for chunks resident in memory) and maintains compatibility with EA IFF. The ckSize value does not include the pad byte.

In this PR, the size includes the padding byte. Which is right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants